/**
 * Ingenius-Group S.A.S
 *
 * Project: SAU
 * File: EditFactorView.java
 * Date: 07/02/2011
 */

package com.ingenius.sau.client.view;

import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.ingenius.sau.client.presenter.EditFactorPresenter.EditFactorDisplay;

/**
 * Class <strong>EditFactorView</strong>
 * 
 * @author Jesus David
 * @version 0.1
 */
public class EditFactorView extends AbstractEditView implements
		EditFactorDisplay {

	// UI Widgets
	private final TextField<String> textName;
	private final TextArea textDescription;

	// Constructor

	public EditFactorView() {
		super();
		textName = new TextField<String>();
		textDescription = new TextArea();

		// TODO i18n
		setHeading("Edit Factor");
		setSize(500, 250);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ingenius.sau.client.mvp.views.AbstractEditView#createComponents()
	 */
	@Override
	protected void createComponents() {
		// TODO i18n
		FormData formData = new FormData("-20");
		textName.setFieldLabel("Name");
		textName.setAllowBlank(false);
		textName.addPlugin(plugin);
		textName.setData("text", "Enter the factor name");
		textName.getMessages().setBlankText("Name is required");

		textDescription.setFieldLabel("Description");
		textDescription.setHeight(75);
		textDescription.setAllowBlank(false);
		textDescription.addPlugin(plugin);
		textDescription.setData("text", "Any description is fine...");
		textDescription.getMessages().setBlankText("Description is required");

		form.add(textName, formData);
		form.add(textDescription, formData);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ingenius.sau.client.mvp.presenters.EditFactorPresenter.EditFactorDisplay
	 * #getName()
	 */
	@Override
	public String getName() {
		return textName.getValue();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ingenius.sau.client.mvp.presenters.EditFactorPresenter.EditFactorDisplay
	 * #setName(java.lang.String)
	 */
	@Override
	public void setName(String name) {
		textName.setValue(name);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ingenius.sau.client.mvp.presenters.EditFactorPresenter.EditFactorDisplay
	 * #getDescription()
	 */
	@Override
	public String getDescription() {
		return textDescription.getValue();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.ingenius.sau.client.mvp.presenters.EditFactorPresenter.EditFactorDisplay
	 * #setDescription(java.lang.String)
	 */
	@Override
	public void setDescription(String description) {
		textDescription.setValue(description);
	}

}
